package com.example.medicine.Mapper;


import com.example.medicine.Bean.dilixinxi;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface dlxxMapper {
    /**
     * 得到全部的地理信息
     *
     * @return
     */
    @Select("select * from [dilixinxi]")
    List<dilixinxi> getAll();

    @Select("select * from [dilixinxi] where id=#{id}")
    dilixinxi getById(int id);

    /**
     * 向地理信息表中插入数据
     * 省份，市，地域，流域
     * 主键自增
     *
     * @param dilixinxi
     */
    @Insert("insert into [dilixinxi](sheng,shi,diyu,liuyu,createuser,createtime) values(#{sheng},#{shi},#{diyu},#{liuyu},#{createuser},GETDATE())")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insert(dilixinxi dilixinxi);

    /**
     * 根据主键（id）更新地理信息库
     * 省，市，地域，流域
     *
     * @param dilixinxi
     */
    @Update("update [dilixinxi] set sheng=#{sheng},shi=#{shi},diyu=#{diyu},liuyu=#{liuyu} where id=#{id}")
    void update(dilixinxi dilixinxi);

    @Delete("delete from [dilixinxi] where id=#{id}")
    void deleteById(int id);
}
